<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var arr = [1, 3, 5, 7, 9]
    var i = 0; //在外面定义一个变量作为判断的标准
    var timer = setInterval(function () {
      console.log(arr[i]);
      i++;
      if (i > arr.length - 1) { //因为i++的原因，所以当i的值大于数组的长度-1的时候，清除定时器
        clearInterval(timer);
      }
    }, 1000)
  </script>
</body>

</html>